Skip to content

fix(ui-kit): stop useStreamingText cancel() from overwriting a settled status - #10121

Merged
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
bitfathers94:fix/issue-10050
Jul 31, 2026
Merged

fix(ui-kit): stop useStreamingText cancel() from overwriting a settled status#10121
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
bitfathers94:fix/issue-10050

Conversation

@bitfathers94

Copy link
Copy Markdown
Contributor

fix(ui-kit): stop useStreamingText cancel() from overwriting a settled status

cancel() only guarded against the per-effect cancelled flag, so once a stream
reached idle/done/error it would still accept a later cancel() and overwrite
the terminal status with "cancelled" - clobbering a completed stream, hiding a
real error behind an inconsistent cancelled+error pair, or flipping an idle
hook that never started a stream. Track settling with its own per-effect flag
and gate cancelRef on it, so cancel() is a no-op once the stream has settled.

Closes #10050

…d status

cancel() only guarded against the per-effect cancelled flag, so once a stream
reached idle/done/error it would still accept a later cancel() and overwrite
the terminal status with "cancelled" - clobbering a completed stream, hiding a
real error behind an inconsistent cancelled+error pair, or flipping an idle
hook that never started a stream. Track settling with its own per-effect flag
and gate cancelRef on it, so cancel() is a no-op once the stream has settled.
@bitfathers94
bitfathers94 requested a review from JSONbored as a code owner July 31, 2026 07:51
@loopover-orb

loopover-orb Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Tip

✅ LoopOver review result - approve/merge recommended

Review updated: 2026-07-31 08:07:36 UTC

2 files · 1 AI reviewer · no blockers · readiness 70/100 · CI green · clean

✅ Suggested Action - Approve/Merge

  • safe to merge

Review summary
This fix adds a per-effect `settled` flag that's set on every terminal transition (idle/done/error) and gates `cancelRef` on both `!cancelled && !settled`, correctly preventing a late `cancel()` from clobbering a settled status. The logic is correct and traced end-to-end: every path that calls `setStatus` to a terminal value also sets `settled = true` before doing so, and `cancelRef.current` checks it before overwriting. The included tests directly exercise the fixed scenarios (idle, done, error, and a status-swap case) rather than fabricating an unreachable state, matching the linked issue #10050.

Nits — 4 non-blocking
  • use-streaming-text.ts: `cancelled` and `settled` are two separate booleans that always end up true together on the terminal paths (done/error) — consider collapsing to a single `phase` variable (e.g. 'active' | 'settled' | 'cancelled') to avoid drift if a future terminal transition forgets to set one of the two flags.
  • use-streaming-text.test.ts: the new describe block duplicates a lot of setup from the existing tests above it (deferredSource push/finish/fail sequences) — could extract a small helper for 'drive to done' / 'drive to error' to cut duplication.
  • Consider consolidating `cancelled` and `settled` into one enum-like state to make it structurally impossible for a future code path to set one without the other (use-streaming-text.ts:46-49).
  • Readiness score is below the configured threshold — Use the readiness panel as advisory maintainer context; the score does not block this PR.

Decision drivers

  • ✅ Code review — No blockers (1 reviewer)
  • ✅ Gate result — Passing (No configured blocker found.)
Context & advisory signals — never blocks the verdict
Signal Result Evidence
Linked issue ✅ Linked #10050
Related work ✅ No active overlap found No same-issue or scoped active PR overlap found.
Change scope ❌ 8/20 High review scope from cached public metadata (1 linked issue).
Validation posture ⚠️ 12/25 Preflight needs author follow-up before maintainer review.
Contributor workload ✅ 10/10 Author activity: 98 registered-repo PR(s), 67 merged, 3 issue(s).
Contributor context ✅ Confirmed Gittensor contributor bitfathers94; Gittensor profile; 98 PR(s), 3 issue(s).
Improvement ✅ Minor risk: clean · value: minor · LLM: moderate
Linked issue satisfaction

Addressed
The diff adds a per-effect `settled` flag set on all three terminal transitions (idle/done/error) and gates cancelRef on it, matching the required pattern exactly, and updates the JSDoc as specified. All listed deliverable tests (null-source, done, error, unchanged in-flight cancel test, and new-source-after-settle) are present in the test file.

Review context
  • Author: bitfathers94
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: not available
  • Official Gittensor activity: 98 PR(s), 3 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Start here: Add a concise scope and risk note.
  • Then work through the remaining 3 steps in the Signals table above.
Signal definitions
  • Related work = same linked issue, overlapping active PRs, or title/path similarity.
  • Change scope = cached public metadata such as size labels, draft state, and review-burden hints.
  • Validation posture = whether the PR provides enough public validation/test evidence for maintainer review.
  • Contributor workload = public contributor activity and cleanup pressure, not a repo-wide quality failure.
  • Contributor context = public GitHub/Gittensor identity context; non-Gittensor status is not a blocker.
🧪 Chat with LoopOver

Ask LoopOver a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.

  • @loopover ask <question> answers contribution-quality Q&A with source citations and freshness.
  • @loopover chat <question> answers in natural prose from cached decision-pack facts via local inference (maintainer/collaborator; read-only).
  • A plain-language @loopover mention with a real question is routed to the closest matching read-only command automatically — no exact syntax required.

Full command reference: https://loopover.ai/docs/loopover-commands

🧪 Experimental — new and may change.

🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed


💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →.

Checked by LoopOver, a quiet PR intelligence layer for OSS maintainers.

  • Re-run LoopOver review

@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@loopover-orb loopover-orb Bot added the gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jul 31, 2026

@loopover-orb loopover-orb Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LoopOver approves — the gate is satisfied and CI is green.

@loopover-orb
loopover-orb Bot merged commit 3d7fdbf into JSONbored:main Jul 31, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ui-kit(hooks): useStreamingText's cancel() overwrites a settled idle/done/error status with "cancelled"

1 participant